#ifndef ENVIRONMENT_H
#define ENVIRONMENT_H

typedef std::unordered_set<RigidBody*> bodySet;

class Environment
{
private:
    uint _width, _height;
    vector3 _gravity;
    bodySet _objects;
    std::vector<Wall> walls;

    void correct(RigidBody *);
public:
    explicit Environment(scalar gravity = 9.8);
    Environment(uint width, uint height, scalar gravity = 9.8);
    Environment(std::initializer_list<RigidBody*>, uint width = 1, uint height = 1, scalar gravity = 9.8);
    virtual ~Environment();

    void addBody(RigidBody*);

    /**
     * Deleted objects are not deallocated
     */
    void delBody(RigidBody*);

    void update(scalar seconds);

    scalar gravity() const;

    void gravity(scalar g);

    uint width() const;

    void width(uint w);

    uint height() const;

    void height(uint h);

    void resize(uint w, uint h);

    const bodySet& bodies() const;
};

#endif // ENVIRONMENT_H
